package n1703;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static int father[]=new int[100001];
	static int rank[]=new int[100001];
	static int father2[]=new int[100001];
	static int rank2[]=new int[100001];
	static int N,M;
	static void init()
	{
		for(int i=0;i<N;i++){
			father[i]=i;
			rank[i]=1;
			father2[i]=i;
			rank2[i]=1;
			last[i]=0;
		}
	}
	
	static int find1(int x)
	{
		if(father[x]!=x)father[x]=find1(father[x]);
		return father[x];
	}
	static int find2(int x)
	{
		if(father2[x]!=x)father2[x]=find2(father2[x]);
		return father2[x];
	}
	
	static void union1(int x,int y)
	{
		x=find1(x);
		y=find1(y);
		if(rank[x]<rank[y])
		{
			father[x]=y;
			rank[y]+=rank[x];
		}else{
			father[y]=x;
			rank[x]+=rank[y];
		}
	}
	static void union2(int x,int y)
	{
		x=find2(x);
		y=find2(y);
		if(rank2[x]<rank2[y])
		{
			father2[x]=y;
			rank2[y]+=rank2[x];
		}else{
			father2[y]=x;
			rank2[x]+=rank2[y];
		}
	}
	
	static int last[]=new int[100001];
	
	/**
	 * @param args
	 */
	public static void main(String[] args)throws Exception {
		// TODO Auto-generated method stub

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		int t=Integer.parseInt(bf.readLine());
		for(int i=0;i<t;i++)
		{
			StringTokenizer st=new StringTokenizer(bf.readLine());
			N=Integer.parseInt(st.nextToken());
			M=Integer.parseInt(st.nextToken());
			init();
			for(int j=0;j<M;j++)
			{
				st=new StringTokenizer(bf.readLine());
				String flag=st.nextToken();

				int n1=Integer.parseInt(st.nextToken());
				int n2=Integer.parseInt(st.nextToken());
				
				if(flag.equals("A"))
				{
					if(find1(n1)!=find1(n2))System.out.println("Not sure yet.");
					else if(find2(n1)==find2(n2))System.out.println("In the same gang.");
					else System.out.println("In different gangs.");
					
					//System.out.println(find2(n1)+","+find2(n2));
				}else{
					union1(n1,n2);
					if(last[n1]!=0){
						union2(last[n1],n2);
					}
					last[n1]=n2;
					if(last[n2]!=0)
					{
						union2(last[n2],n1);
					}
					last[n2]=n1;
				}
			}
		}
	}

}
